package com.mk.web.proxy.jdk;

import java.lang.reflect.Proxy;

/**
 * 客户
 * Created by WangChen on 2018/11/29 13:46.
 */
public class Client {

    public static void main(String [] args){

        Secretary secretary = new Secretary();

        Function proxyInstance =
                (Function) Proxy.newProxyInstance(Client.class.getClassLoader(), new Class[]{Function.class}, secretary);

        /**
         * Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to com.mk.web.proxy.jdk.Boss
         */
//        Boss boss = (Boss) proxyInstance;

        proxyInstance.talk();

    }
}
